      subroutine axpyso2(nsize, fact, iin, ioffin, iout, ioffout)
      use cublas, only:cublassaxpy, cublasdaxpy 
      implicit none 
      integer prec, isd, igpu
      common/precsoc/prec, isd, igpu
      integer, intent(in) :: nsize, ioffin, ioffout 
      real*4, intent(in),managed :: iin(*), iout(*) 
      real*8, intent(in) :: fact
      real*4 fact4
      integer*4 ioffin4, ioffout4, nsize4 
C
      if(prec==8.and.igpu==0) then 
         call daxpy(nsize, fact, iin, ioffin, iout, ioffout)  
      elseif(prec==4.and.igpu==0) then 
         fact4 = fact
         call saxpy(nsize, fact4, iin, ioffin, iout, ioffout)
      elseif(prec==8.and.igpu==1) then
!          write(6,*)'test gpu'
          call daxpyg2(nsize, fact, iin, ioffin, iout, ioffout)  
      elseif(prec==4.and.igpu==1) then 
          call saxpyg2(nsize4, fact4, iin, ioffin4, iout, ioffout4)
      endif
      return
      end
       
      subroutine daxpyg2(nsize, fact, iin, ioffin, iout, ioffout)
      implicit none 
      integer, intent(in) :: nsize, ioffin, ioffout 
      real*8, intent(in), device :: iin(*), iout(*) 
      real*8, intent(in) :: fact
      integer i 
      write(6,*)'daxpyg2', i, nsize, ioffin, ioffout
!$acc parallel loop
      do i = 1, nsize 
         iout(i) = iout(i) + fact*iin(i) 
      enddo
!$acc end parallel loop
      return
      end

      subroutine saxpyg2(nsize, fact, iin, ioffin, iout, ioffout)
      implicit none
      integer, intent(in) :: nsize, ioffin, ioffout
      real*4, intent(in), device :: iin(*), iout(*)
      real*8, intent(in) :: fact
      integer i
!$acc parallel loop
      do i = 1, nsize
         iout(i+ioffout-1) = iout(i+ioffout-1) + fact*iin(i+ioffin-1)
      enddo
!$acc end parallel loop
      return
      end
       
       
